using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NTTHAO.Web.BL.Survey;
using NTTHAO.CommonWeb;

public partial class admin_webparts_Plug_ins_Survey_SurveyDetailInput : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.btnSave2.Text = this.btnSave.Text = LanguageUtility.GetLanguageText("SAVE", Session);
        this.chkActive.Text = LanguageUtility.GetLanguageText("ACTIVE", Session);

        if (!IsPostBack)
        {
            try
            {
                if (Request.QueryString["detailid"] != null)
                {
                    SurveyDetail sur = new SurveyDetail(Int32.Parse(Request.QueryString["detailid"]));
                    this.txtDescription.Text = sur.Description;
                    this.chkActive.Checked = sur.Actived;
                }
            }
            catch (Exception)
            {
            }
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            SurveyDetail surveyDetail = null;

            if (Request.QueryString["detailid"] != null)
            {
                surveyDetail = new SurveyDetail(Int32.Parse(Request.QueryString["detailid"]));
            }
            else
            {
                surveyDetail = new SurveyDetail();
                surveyDetail.SurveyID = Int32.Parse(Request.QueryString["surveyid"]);
            }
            surveyDetail.Description = txtDescription.Text;
            surveyDetail.Actived = chkActive.Checked;

            if (Request.QueryString["detailid"] != null)
            {
                surveyDetail.Update();
            }
            else
            {
                surveyDetail.Insert();
            }

            Response.Redirect("?type=" + Request.QueryString["type"] + "&name=" + Request.QueryString["name"] + "&action=surveyview&surveyid=" + Request.QueryString["surveyid"], false);
        }
        catch (Exception)
        {
        }
    }
}
